//
//  ThreeViewController.m
//  TestDemo
//
//  Created by apple on 2022/1/15.
//

#import "ThreeViewController.h"
#import "Student.h"
#import "Animal.h"


@interface ThreeViewController ()
@property(nonatomic,strong)Student * st;

@property(nonatomic,strong)Animal * ani;

@end

@implementation ThreeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
    
    self.st = [Student instanceStudent];
    self.ani = [[Animal alloc]init];
    
    [self.ani addObserver:self forKeyPath:@"name" options:NSKeyValueObservingOptionNew context:NULL];
    [self.st addObserver:self forKeyPath:@"name" options:NSKeyValueObservingOptionNew context:NULL];

}

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [super touchesBegan:touches withEvent:event];
    
    self.st.name = @"李辉";
    self.ani.name = @"小黄";
    
}


-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context{
    
    
}

-(void)dealloc{
//    [self.ani removeObserver:self forKeyPath:@"name"];
//    [self.st removeObserver:self forKeyPath:@"name"];
    
    NSLog(@"%s",__func__);
    
}



@end
